package ch11;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

public class _06_ArrayListLinkedListTest2 { 
      public static void main(String args[]) { 
            ArrayList<Integer> al = new ArrayList<Integer>(1000000); 
            LinkedList<Integer> ll = new LinkedList<Integer>(); 
	        add(al);
            add(ll);

            System.out.println("ArrayList :"+access(al)); // ArrayList :2
            System.out.println("LinkedList :"+access(ll)); // LinkedList :141
	  }

      public static void add(List<Integer> list) { 
            for(int i=0; i<100000;i++) list.add(i); 
      } 

      public static long access(List<Integer> list) { 
            long start = System.currentTimeMillis(); 
            for(int i=0; i<10000;i++) list.get(i); 
            long end = System.currentTimeMillis(); 
            return end - start; 
      } 
}
/*
ArrayList :1
LinkedList :279
*/